#!/bin/bash

# 阿里云前缀
aliyun_registry="registry.aliyuncs.com/google_containers"

# 官方前缀
official_registry="registry.k8s.io"

# 镜像列表
#images=(
#"kube-apiserver:v1.25.10"
#"kube-controller-manager:v1.25.10"
#"kube-scheduler:v1.25.10"
#"kube-proxy:v1.25.10"
#"pause:3.8"
#"etcd:3.5.4-0"
#)

  images=(
  "kube-apiserver:v1.27.2"
  "kube-controller-manager:v1.27.2"
  "kube-scheduler:v1.27.2"
  "kube-proxy:v1.27.2"
  "pause:3.9"
  "etcd:3.5.7-0"
  )

for image in "${images[@]}"
do
   echo "Pulling ${aliyun_registry}/${image}"
   docker pull ${aliyun_registry}/${image}

   echo "Tagging ${aliyun_registry}/${image} to ${official_registry}/${image}"
   docker tag ${aliyun_registry}/${image} ${official_registry}/${image}

   echo "Removing ${aliyun_registry}/${image}"
   docker rmi ${aliyun_registry}/${image}
done

#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.9.3
#docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.9.3 ${official_registry}/"coredns/coredns:v1.9.3"
#docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.9.3

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.10.1
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.10.1 ${official_registry}/"coredns/coredns:v1.10.1"
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.10.1